package com.itheima.TCP;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class ClientDemo01 {
    public static void main(String[] args) throws IOException {
        //创建该Socket类，指向IP为127.0.0.1的主机的10086端口
        Socket socket = new Socket("127.0.0.1",10086);
        //获得连接上面主机端口的输出流
        OutputStream os = socket.getOutputStream();
        byte[] bytes = "Hello Java".getBytes();
        //写出数据
        os.write(bytes);
        //在关闭socket时，也会关闭os
        socket.close();
    }
}
